#!/usr/bin/env python3
"""
MCP Server 启动入口
"""

import asyncio
import os
import sys
from pathlib import Path

# Add the project root to the Python path
project_root = Path(__file__).parent
sys.path.insert(0, str(project_root))

from src.server import main

if __name__ == "__main__":
    # Load environment variables
    from dotenv import load_dotenv
    load_dotenv()
    
    # Check for API key
    if not os.getenv("ZHIPU_API_KEY"):
        print("❌ 错误: ZHIPU_API_KEY环境变量必须设置")
        print("请运行: export ZHIPU_API_KEY='your_api_key'")
        sys.exit(1)
    
    print("🚀 启动CogView MCP Server...")
    print("💡 在Cline中配置:")
    print("   command: python")
    print(f"   args: ['{project_root}/server_main.py']")
    print("   env: ZHIPU_API_KEY=your_api_key")
    print("=" * 50)
    
    asyncio.run(main())
